<?php
class MY_Controller extends CI_Controller
{
    public function __construct(){
        parent::__construct();
        
        header("Content-type: text/html; charset=utf-8");
        ini_set('session.gc_maxlifetime',288000);
        
        $this->img_host = "http://www.tan66.com";
        $this->bgType = setting("bg_type");
        $this->assign("style_dir", STYLE_DIR);//全局样式路径
    }
    
    public function assign($key,$val) {   
        $this->cismarty->assign($key,$val);   
    }

    public function display($html) {   
        $this->cismarty->display($html);   
    }
    //设置时间进度2
    public function set_time_two($time){
        $curent_time = time();
        $_second = $curent_time - $time;
        $_time = $_second / 60;//分钟
        if($_time < 1){
            return $_second."秒前";
        }

        if($_time > 1 && $_time < 60){
            return intval($_time)."分前";
        }

        if($_time > 60 && $_time < 1440){
            return intval($_time / 60) ."小时前";
        }

        if($_time > 1440){
            return date("Y-m-d",$time);
        }
    }

    public function set_time_three($time){
        $curent_time = time();
        $_second = $curent_time - $time;
        $_time = $_second / 60;//分钟
        if($_time < 1){
            return $_second."秒前";
        }
        
        if($_time > 1 && $_time < 60){
            return intval($_time)."分前";
        }
        
        if($_time > 60 && $_time < 1440){
            return intval($_time / 60) ."小时前";
        }
        
        if($_time > 1440){
            return intval($_time / 1440) ."天前";
        }
    }
}